<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="lib/css/bootstrap.css">
    <title>Document</title>
    <style>
        .container{
            margin-top: 60px;
           
        }
        .btn1{
            width: 950px;
            height: 40px;
            font-size: 20px;
        }
    </style>
</head>
<body>
    <div class="container">
        <form>
            <input type="file" name="photo" id="">
            <br>
            <input type="submit" class="btn btn-success btn1" value="上&#x3000;传">
        </form>
    </div>

    <script src="lib/jquery.js"></script>
    <script src="lib/js/bootstrap.js"></script>

    <script>
        $("form").submit(function(e){
            e.preventDefault();

             var form = new FormData(this);
            $.post({
                url: '/user',
                data: form,
                processData: false,
                contentType: false,
                complete: function (res) {
                    if (res.responseJSON.code == 'success') {
                        location.href = '/';
                    }else alert(rew.responseJSON.msg);
                }
            })
        })
    </script>
    

</body>
</html>